package com.practices2.activity;

import org.apache.http.entity.mime.MinimalField;

import android.os.Bundle;
import android.os.Handler;
import android.view.Window;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationUtils;

import com.practices2.R;
import com.practices2.base.BaseActivity;

public class SplashScreenActivity extends BaseActivity {
	public final static String FIRST_RUN_PREFERENCE = "first_run";

	private Animation endAnimation;
	private Handler endAnimationHandler;
	private Runnable endAnimationRunnable;

	/*
	 * (non-Javadoc)
	 * 
	 * @see android.app.Activity#onCreate(android.os.Bundle)
	 */
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);

		// TODO
		// setContentView(R.layout.splashscreen);
		// findViewById(R.id.splashlayout);

		endAnimation = AnimationUtils.loadAnimation(this, R.anim.push_left_in);
		endAnimation.setFillAfter(true);

		endAnimationHandler = new Handler();
		endAnimationRunnable = new Runnable() {
			@Override
			public void run() {

				// TODO
				// findViewById(R.id.splashlayout).startAnimation(endAnimation);
			}
		};

		endAnimation.setAnimationListener(new AnimationListener() {
			@Override
			public void onAnimationStart(Animation animation) {

			}

			@Override
			public void onAnimationRepeat(Animation animation) {
			}

			@Override
			public void onAnimationEnd(Animation animation) {
				MainActivity.launch(SplashScreenActivity.this);
				SplashScreenActivity.this.finish();
			}
		});

		// showTutorial();
	}

	// final void showTutorial() {
	// boolean showTutorial =
	// PreferenceManager.getDefaultSharedPreferences(this).getBoolean(FIRST_RUN_PREFERENCE,
	// true);
	// if (showTutorial) {
	// final TutorialDialog dlg = new TutorialDialog(this);
	// dlg.setOnDismissListener(new DialogInterface.OnDismissListener() {
	// @Override
	// public void onDismiss(DialogInterface dialog) {
	// CheckBox cb = (CheckBox) dlg.findViewById(R.id.toggleFirstRun);
	// if (cb != null && cb.isChecked()) {
	// SharedPreferences prefs =
	// PreferenceManager.getDefaultSharedPreferences(SplashscreenActivity.this);
	// prefs.edit().putBoolean(FIRST_RUN_PREFERENCE, false).commit();
	// }
	// endAnimationHandler.removeCallbacks(endAnimationRunnable);
	// endAnimationHandler.postDelayed(endAnimationRunnable, 2000);
	// }
	// });
	// dlg.show();
	// } else {
	// endAnimationHandler.removeCallbacks(endAnimationRunnable);
	// endAnimationHandler.postDelayed(endAnimationRunnable, 1500);
	// }
	// }
}
